package com.qiaoyanqing.ximalaya.discovermodule.discover_adapter;

import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.qiaoyanqing.ximalaya.R;
import com.qiaoyanqing.ximalaya.discovermodule.discover_entity.DiscoverAlbumShowEntity;
import com.qiaoyanqing.ximalaya.util.CircleTransform;
import com.squareup.picasso.Picasso;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/9.
 */

public class DiscoverAlbumShowLVadapter extends BaseAdapter {

    private List<DiscoverAlbumShowEntity.DataBean.TracksBean.ListBean>mData=new ArrayList<>();
    private Context mContext;

    public DiscoverAlbumShowLVadapter(List<DiscoverAlbumShowEntity.DataBean.TracksBean.ListBean> data, Context context) {
        mData = data;
        mContext = context;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int i) {
        return mData.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        ViewHolder holder=null;

        if (view == null) {
            holder=new ViewHolder();
            view= LayoutInflater.from(mContext).inflate(R.layout.albumshow,viewGroup,false);
            holder.title= (TextView) view.findViewById(R.id.showtitle);
            holder.imageview= (ImageView) view.findViewById(R.id.showimage);
//            holder.num1= (TextView) view.findViewById(R.id.showplatcount);
//            holder.num2= (TextView) view.findViewById(R.id.showtime);
//            holder.num3= (TextView) view.findViewById(R.id.showmsg);
            view.setTag(holder);

        }else {
            holder= (ViewHolder) view.getTag();

        }
        //赋值


        String  emptypath="http://fdfs.xmcdn.com/group10/M07/CB/31/wKgDaVZxIG7y6MciAADXlSjVU68904_mobile_small.jpg";
        holder.title.setText(mData.get(i).getTitle()!=null?mData.get(i).getTitle():"喜马拉雅FM");

        if (mData.get(i).getCoverSmall()!=null){
            Picasso.with(mContext).load(mData.get(i).getCoverSmall()).transform(new CircleTransform()).into(holder.imageview);
        }else {
            Picasso.with(mContext).load(emptypath).transform(new CircleTransform()).into(holder.imageview);
        }



        return view;
    }

    static class ViewHolder{
        ImageView imageview;
        TextView title,num1,num2,num3,time;


    }

}
